<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>岗位管理</title>

    <!-- Bootstrap -->
    <link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet">
    <link href="<%=basePath%>css/lastStyle.css" rel="stylesheet">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

  </head>
  <body>
<!-- 导航 -->
     <nav class="navbar navbar-default ">
      <div class="container">

        <!-- 小屏幕按钮和logo -->
        <div class="navbar-header">
          <button class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a href="#" class="navbar-brand">RM admin</a>
        </div>

        <!-- 小屏幕按钮和logo -->
        <!-- 导航 -->
        <div class="collapse navbar-collapse">
           <ul class=" nav navbar-nav ">
             <li class="active"><a href="#"><span class="glyphicon glyphicon-home"></span> &nbsp;后台首页</a></li>
             <li class="dropdown">
                <a href="organization.html" class="dropdown-toggle" data-toggle="dropdown">
                   组织结构管理
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="${pageContext.request.contextPath }/organization/department">部门管理</a></li>
                    <li><a href="${pageContext.request.contextPath }/organization/job">岗位管理</a></li>

                </ul>
            </li>
            <li class="dropdown">
                <a href="organization.html" class="dropdown-toggle" data-toggle="dropdown">
                    人事信息管理
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="${pageContext.request.contextPath }/employee/enterAddEmployee">员工入职管理</a></li>
                    <li><a href="${pageContext.request.contextPath }/period/enterPeriod/">试用期管理</a></li>
                    <li><a href="${pageContext.request.contextPath }/dept/out">部门调动管理</a></li>
                    <li><a href="${pageContext.request.contextPath }/post/out">岗位调动管理</a></li>
                    <li><a href="${pageContext.request.contextPath }/leave/out">员工离职管理</a></li>

                </ul>
            </li>
             <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                    员工信息中心
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="${pageContext.request.contextPath }/infoemployee/list">员工信息中心</a></li>


                </ul>
            </li>
            <li class="dropdown">
                <a href="organization.html" class="dropdown-toggle" data-toggle="dropdown">
                    报表管理
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="${pageContext.request.contextPath }/statement/newHire">新聘员工报表</a></li>
                    <li><a href="${pageContext.request.contextPath }/statement/departure">离职员工报表</a></li>
                    <li><a href="${pageContext.request.contextPath }/statement/deptTurn">部门调动员工报表</a></li>
                    <li><a href="${pageContext.request.contextPath }/statement/postTurn">岗位调动员工报表</a></li>
                </ul>
            </li>
           </ul>
           <ul class=" nav navbar-nav navbar-right ">
             <li class="dropdown">
                <a href="#" class=" dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown">admin
                    <span class="caret"></span>
                </a>
            </li>

             <li><a href="http://localhost:8080/PMsystem/admin/exit"><span class="glyphicon glyphicon-off"></span>&nbsp;退出</a></li>
           </ul>
        </div>
        <!-- 导航 -->
      </div>
    </nav>
   <!-- 导航 -->
   <div class="container-fluid">
       <div class="row">
           <div class="col-md-2">
               <div class="panel-group" id="accordion">
                  <div class="panel panel-default">
                      <div class="panel-heading">
                          <h4 class="panel-title">
                              <a data-toggle="collapse" data-parent="#accordion"
                              href="#collapseOne" style="text-decoration: none;">
                             岗位操作
                              </a>
                          </h4>
                      </div>
                     <div id="collapseOne" class="panel-collapse collapse in">
                          <div class="panel-body">
                             <table class="table table-hover">
                              <tbody>
                                <tr>
                                <tr>
                                  <td><a href="job-add" style="text-decoration: none;">新建岗位</a></td>
                                </tr>
                                <!-- <tr>
                                  <td><a href="xiangqingdepartment.html" style="text-decoration: none;">修改部门</a></td>
                                </tr> -->
                                <tr><td ><a href="${pageContext.request.contextPath }/organization/job" style="text-decoration: none;">查询岗位</a></td>
                                 </tr>
                                <!--  <td ><a href="#" style="text-decoration: none;">查询部门下员工</a></td> -->
                                </tr>
                              </tbody>
                            </table>
                          </div>
                      </div>
                  </div>


              </div>

           </div>
           <div class="col-sm-10">
           <!-- 主体内容 -->

           <div class="panel panel-info">
              <div class="panel-heading">
                  <h3 class="panel-title">查询岗位</h3>
              </div>
              <div class="panel-body">
                  <form class="form-inline" role="form" action="job-search" method="post">
                     <div class="input-group">
                        <span class="input-group-addon">编号</span>
                        <input type="text" name="postId" class="form-control" placeholder="请输入编号">
                    </div>--
                    <div class="input-group">
                        <span class="input-group-addon">名称</span>
                        <input type="text" name="postName" class="form-control" placeholder="请输入名称">
                    </div>--
                    <div class="input-group">
                        <span class="input-group-addon">岗位类型</span>
	                    <input type="hidden" id="postType1" name="postType" value=""/>
	                    <select class="form-control" id="postTypeBox"  onchange="choiceType1(this)">
	                      <option value="0">管理</option>
	                      <option value="1">技术</option>
	                      <option value="2">营销</option>
	                      <option value="3">市场</option>
	                    </select>
                    </div>
                    &nbsp &nbsp &nbsp &nbsp<button type="submit" class="btn btn-info" >查询</a></button>
                    </form>
                </div>
             </div>
       <table class="table table-bordered">
  <caption>部门列表</caption>
  <thead>
    <tr>
      <th>编号</th>
      <th>名称</th>
      <th>岗位类型</th>
      <th>岗位编制</th>
      <th>操作</th>
    </tr>
  </thead>
  <tbody> 
  <c:forEach items="${jobList }" var="jobItem" varStatus="index">
  <tr>
    <td>${jobItem.postId }</td>
      <td>${jobItem.postName }</td>
      <td>${jobItem.postType }</td>
      <td>${jobItem.postWeave }</td>
       <td width="300px">

            <!-- 按钮触发模态框 -->
            <button class="btn btn-primary " onclick="editor(${jobItem.postId })" data-toggle="modal" data-target="#myModal">
              修改信息</button>
             <button class="btn btn-primary "><a href="${pageContext.request.contextPath }/post/out" style="color: white">
             查询员工</a></button>
              
             <button type="button" class="btn btn-danger"  onclick='deleteItem(${jobItem.postId })'>删除信息</button>
      </td>
    </tr>
   </c:forEach>
  </tbody>
</table>
 
           </div>



           </div>
       </div>





<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
          &times;
        </button>
        <h4 class="modal-title" id="myModalLabel">
          修改岗位信息
        </h4>
      </div>
      <div class="modal-body">
         <form id="updateForm" class="bs-example bs-example-form" role="form">
                    <div class="input-group ">
                        <span class="input-group-addon">编号</span>
                        <input type="text" class="form-control" id="postId1" disabled="disabled" placeholder="请输入编号">
                        <input type="hidden" class="form-control" id="postId" name="postId" placeholder="请输入编号">
                    </div>
                    <br>
                    <div class="input-group ">
                     <span class="input-group-addon">名称</span>
                        <input type="text" class="form-control" id="postName" name="postName" placeholder="请输入名称">
                    </div>
                    <br>
                    <div class="input-group ">
                    <span class="input-group-addon">岗位类型</span>
                        <input type="hidden" id="postType" name="postType" value=""/>
	                    <select class="form-control" id="postTypeBox"  onchange="choiceType(this)">
	                      <option value="0" selected="selected">管理</option>
	                      <option value="1">技术</option>
	                      <option value="2">营销</option>
	                      <option value="3">市场</option>
	                    </select>
                    </div>
                    <br>
                    <div class="input-group ">
                    <span class="input-group-addon">岗位编制</span>
                        <input type="text" class="form-control" id="postWeave" name="postWeave" placeholder="请输入电话号码">
                    </div>
                    <br>
                </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭
        </button>
        <button type="button" onclick="update()" class="btn btn-primary">
          提交更改
        </button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal -->
</div>





    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="<%=basePath%>js/jquery-3.2.1.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="<%=basePath%>js/bootstrap.min.js"></script>
    <script>
    function deleteItem(postId){
    	$.get("job-del?postId="+postId,function(data){
    		if(data = "success"){
	    		alert("删除成功！！");
	    		location.reload();
    		}
    	});
    }
    
    function editor(postId){
    	$.get("job-edit?postId="+postId,function(data){
    		console.log(data);
    		$("#postId").val(data.postId);
    		$("#postId1").val(data.postId);
    		$("#postName").val(data.postName);
    		$("#postType").val(data.postType);
    		$("#postTypeBox option").each(function(key, value){
    			//alert($(value).val());
    			if(data.postType == $(value).val()){
    				$(value).attr("selected","selected");
    			}
    		});
    		$("#postWeave").val(data.postWeave);
    	});
    }
    
    function update(postId){
    	$.post("job-update",$("#updateForm").serialize(), function(data){
    		console.log(data);
    		if(data = "success"){
	    		alert("修改成功！！");
	    		location.reload();
    		}
    	});
    }
    
    function choiceType(e){
			//alert($(e).val());
			$("#postType").val($(e).val());
		} 
    
    function choiceType1(e){
		//alert($(e).val());
		$("#postType1").val($(e).val());
	} 
    </script>
  </body>
</html>